<?
    require_once("mvc/action/ActionForm.php");
    require_once("mvc/action/ActionMessage.php");
    require_once("mvc/action/ActionMessages.php");

    require_once("cms/gallery/om/Gallery.php");


    class BaseGalleryForm extends ActionForm {

        protected $gallery;
        protected $formImage;
        protected $deleteImage;

        public function __construct() {
            $this->gallery = new Gallery();
            $this->formImage = null;
            $this->deleteImage = false;
        }

        public function getGallery() {
            return $this->gallery;
        }

        public function setGallery(Gallery $gallery) {
            $this->gallery = $gallery;
        }

        public function getFormImage() {
            return $this->formImage;
        }

        public function setFormImage($formImage) {
            $this->formImage = $formImage;
        }

        public function getDeleteImage() {
            return $this->deleteImage;
        }

        public function setDeleteImage($deleteImage) {
            $this->deleteImage = $deleteImage;
        }

        public function validate() {

            $errors = new ActionMessages();

            if(is_null($this->getGallery()->getName()) || strlen($this->getGallery()->getName()) == 0)
                $errors->add("gallery->name",
                    new ActionMessage("errors.required", true, new ActionMessage("prompt.name", true)));


            if(!is_null($this->getGallery()->getName()) && strlen($this->getGallery()->getName()) > 0 && strlen($this->getGallery()->getName()) > 255)
                $errors->add("gallery->name",
                    new ActionMessage("errors.maxlength", true, array(
                        new ActionMessage("prompt.name", true),
                        new ActionMessage("255", false))));


            return $errors;
        }

    }
?>